package com.jffccloud.auth.model;

import org.apache.commons.lang3.StringUtils;

/**
 * @author itdever(itdever@163.com)
 * @version 1.0
 *          功能说明：资源类型
 */
public enum ResType {
    MENU(0, "菜单"),
    FUN(1, "功能"),
    FUNATTR(2, "功能属性"),
    FUNEVENT(3, "功能事件"),
    DATAPRIVILEGE(4, "数据权限");

    /**
     * 组件类型
     */
    int type;

    /**
     * 组件描述
     */
    String label;


    ResType(int type, String label) {
        this.type = type;
        this.label = label;
    }

    public int getType() {
        return type;
    }


    public String getLabel() {
        return label;
    }


    public static ResType convertion(String type) {
        if (StringUtils.equals(type, "0")) {
            return MENU;
        } else if (StringUtils.equals(type, "1")) {
            return FUN;
        } else if (StringUtils.equals(type, "2")) {
            return FUNATTR;
        } else if (StringUtils.equals(type, "3")) {
            return FUNEVENT;
        } else if (StringUtils.equals(type, "4")) {
            return DATAPRIVILEGE;
        }
        return null;
    }

}
